import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
import axios from 'axios'
axios.defaults.baseURL = 'http://10.11.4.93:8010/'
Vue.prototype.$http = axios
const staticRequest = axios.create({
  baseURL: './'
})
Vue.prototype.$static = staticRequest
Vue.config.productionTip = false

// 路由守卫
router.beforeEach((to, from, next) => {
  let isLogin = window.sessionStorage.getItem('userId')
  if (isLogin) {
    next()
  } else {
    if (to.path === '/login') {
      next()
    } else {
      window.alert('您还没有登录，请先登录')
    }
  }
})

new Vue({
  router,
  store,
  render: (h) => h(App)
}).$mount('#app')
